//
//  HomeRecommendCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/5/16.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "HomeRecommendCell.h"
#import "SectionView.h"

@interface  HomeRecommendCell()

@property(nonatomic,strong)SectionView *sectionView;

@end

@implementation HomeRecommendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self buildSubViews];
    }
    return self;
}

- (void)buildSubViews
{
    [self.contentView addSubview:self.sectionView];
    
    CGFloat leftMargin = 15;
    CGFloat centerMargin = 10;
    CGFloat ViewW = (WIDTH - leftMargin*2 - centerMargin*2)/3;
    
    for (int i = 0; i < 3; ++i) {
        
        UIImageView *toolView = [[UIImageView alloc] init];
        toolView.image = [UIImage imageNamed:[NSString stringWithFormat:@"bg_recommend%d",i]];
        toolView.userInteractionEnabled = true;
        toolView.tag = i;
        [toolView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(recommendClick:)]];
        [self.contentView addSubview:toolView];
        
        toolView.frame = CGRectMake(leftMargin + i*(ViewW+centerMargin),CGRectGetMaxY(self.sectionView.frame),ViewW,140);
    }
}

- (void)recommendClick:(UIGestureRecognizer *)recognizer
{
    
}


#pragma mark lazy
- (SectionView *)sectionView
{
    if (!_sectionView) {
        _sectionView = [[SectionView alloc] initWithFrame:CGRectMake(0,0,WIDTH,40)];
        _sectionView.titleLabel.text = @"超值推荐";
    }
    return _sectionView;
}

@end
